package com.maple.utils.db

import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "User")
class User(): Parcelable {

    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id")
    var id: Long = 0
    @ColumnInfo(name = "user_id")
    var userId: String? = ""
    @ColumnInfo(name = "user_name")
    var userName: String? = ""
    @ColumnInfo(name = "nick_name")
    var nickName: String? = ""
    @ColumnInfo(name = "account")
    var account: String? = ""
    @ColumnInfo(name = "password")
    var password: String? = ""
    @ColumnInfo(name = "sign")
    var sign: String? = ""
    @ColumnInfo(name = "phone")
    var phone: String? = ""
    @ColumnInfo(name = "gender")
    var gender: String? = ""
    @ColumnInfo(name = "avatar")
    var avatar: String? = ""
    @ColumnInfo(name = "email")
    var email: String? = ""
    @ColumnInfo(name = "token")
    var token: String? = ""
    @ColumnInfo(name = "status")
    var status: String? = ""
    @ColumnInfo(name = "create_time")
    var createTime: String? = ""
    @ColumnInfo(name = "create_by")
    var createBy: String? = ""
    @ColumnInfo(name = "login_ip")
    var loginIp: String? = ""
    @ColumnInfo(name = "login_date")
    var loginDate: String? = ""

    @ColumnInfo(name = "dept_id")
    var deptId: String? = ""
    @ColumnInfo(name = "parent_id")
    var parentId: String? = ""
    @ColumnInfo(name = "dept_name")
    var deptName: String? = ""

    @ColumnInfo(name = "role_id")
    var roleId: String? = ""
    @ColumnInfo(name = "role_name")
    var roleName: String? = ""
    @ColumnInfo(name = "role_key")
    var roleKey: String? = ""

    @ColumnInfo(name = "json")
    var json: String? = ""

    constructor(parcel: Parcel) : this() {
        id = parcel.readLong()
        userId = parcel.readString()
        userName = parcel.readString()
        nickName = parcel.readString()
        account = parcel.readString()
        password = parcel.readString()
        sign = parcel.readString()
        phone = parcel.readString()
        gender = parcel.readString()
        avatar = parcel.readString()
        email = parcel.readString()
        token = parcel.readString()
        status = parcel.readString()
        createTime = parcel.readString()
        createBy = parcel.readString()
        loginIp = parcel.readString()
        loginDate = parcel.readString()
        deptId = parcel.readString()
        parentId = parcel.readString()
        deptName = parcel.readString()
        roleId = parcel.readString()
        roleName = parcel.readString()
        roleKey = parcel.readString()
        json = parcel.readString()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(id)
        parcel.writeString(userId)
        parcel.writeString(userName)
        parcel.writeString(nickName)
        parcel.writeString(account)
        parcel.writeString(password)
        parcel.writeString(sign)
        parcel.writeString(phone)
        parcel.writeString(gender)
        parcel.writeString(avatar)
        parcel.writeString(email)
        parcel.writeString(token)
        parcel.writeString(status)
        parcel.writeString(createTime)
        parcel.writeString(createBy)
        parcel.writeString(loginIp)
        parcel.writeString(loginDate)
        parcel.writeString(deptId)
        parcel.writeString(parentId)
        parcel.writeString(deptName)
        parcel.writeString(roleId)
        parcel.writeString(roleName)
        parcel.writeString(roleKey)
        parcel.writeString(json)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<User> {
        override fun createFromParcel(parcel: Parcel): User {
            return User(parcel)
        }

        override fun newArray(size: Int): Array<User?> {
            return arrayOfNulls(size)
        }
    }
}